use serialize::{Decodable};
use hammer::{FlagDecoder,FlagConfig,FlagConfiguration,HammerError};
use std::io;
+use std::os;
use std::io::BufReader;
use std::io::process::{Process,ProcessExit,ProcessOutput,InheritFd,ProcessConfig};
use {ToCargoError,CargoResult};
+use util::config::{get_config,all_configs};
#[deriving(Decodable)]
struct Options {
pub fn compile() -> CargoResult<()> {
let options = try!(flags::<Options>());
- let manifest_bytes = try!(read_manifest(options.manifest_path).to_cargo_error(~"Could not read manifest", 1));
+ let manifest_bytes = try!(read_manifest(options.manifest_path));
call_rustc(~BufReader::new(manifest_bytes.as_slice()))
}
}
fn exec(program: &str, args: &[~str], input: Option<&mut Reader>, configurator: |&mut ProcessConfig|) -> CargoResult<Process> {
+ let paths = get_config(os::getcwd(), "source-paths");
+
let mut config = ProcessConfig::new();
config.program = program;
config.args = args;
println!("Executing {} {}", program, args);
- let mut process = try!(Process::configure(config).to_cargo_error(~"Could not configure process", 1));
+ let mut process = try!(Process::configure(config).to_cargo_error(|e: io::IoError| format!("Could not configure process: {}", e), 1));
input.map(|mut reader| io::util::copy(&mut reader, process.stdin.get_mut_ref()));
extern crate collections;
extern crate toml;
-use super::super::{CargoResult,ToCargoError};
+use super::super::{CargoResult,ToCargoError,CargoError};
use std::{io,fmt};
#[deriving(Eq,TotalEq,Clone,Encodable,Decodable)]
Global
}
+#[deriving(Eq,TotalEq,Clone,Encodable,Decodable,Show)]
+enum ConfigValueValue {
+ String(~str),
+ List(~[~str])
+}
+
#[deriving(Eq,TotalEq,Clone,Encodable,Decodable)]
pub struct ConfigValue {
- value: ~str,
+ value: ConfigValueValue,
path: ~str
}
let path = try!(file.path().as_str().to_cargo_error(~"", 1)).to_owned();
let mut buf = io::BufferedReader::new(file);
let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error(~"", 1));
- let val = try!(try!(root.lookup(key).to_cargo_error(~"", 1)).get_str().to_cargo_error(~"", 1));
- Ok(ConfigValue{ value: val.to_owned(), path: path })
+ let val = try!(root.lookup(key).to_cargo_error(~"", 1));
+
+ let v = match val {
+ &toml::String(ref val) => String(val.to_owned()),
+ &toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| s.to_str()).collect()),
+ _ => return Err(CargoError::new(~"", 1))
+ };
+
+ Ok(ConfigValue{ value: v, path: path })
}
fn extract_all_configs(file: io::fs::File) -> CargoResult<collections::HashMap<~str, ConfigValue>> {
for (key, value) in table.iter() {
match value {
- &toml::String(ref val) => { map.insert(key.to_owned(), ConfigValue { value: val.to_owned(), path: path.clone() }); }
+ &toml::String(ref val) => { map.insert(key.to_owned(), ConfigValue { value: String(val.to_owned()), path: path.clone() }); }
+ &toml::Array(ref val) => { map.insert(key.to_owned(), ConfigValue { value: List(val.iter().map(|s: &toml::Value| s.to_str()).collect()), path: path.clone() }); }
_ => ()
}
}